<%@page import="util.Constants"%>
<%@page import="blo.DictionariesBLO"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@page import="dao.LanguagesDAO"%>
<%@page import="dao.DictionariesDAO"%>
<%@page import="blo.LanguagesBLO"%>
<%@page import="javax.servlet.*" %>

<%-- 
<h2>Translation</h2>
<br>From ${param.From}
<br>To ${param.To}
<br>LMOODE ${param.LMode}
<br>INPUT ${param.WInput}
<br>DICTID ${param.DictionaryID}
--%>

<%
	// Firstly, Get The Word input
	String WTS = request.getParameter("WInput");
	if(WTS == null || WTS == Constants.BLANK_STRING){//If User click the button without an input :
		out.print("<font size='2' color='blue'>PLEASE ENTER A WORD TO USE LOOKING UP FUNCTION <//font>");
	}else{
		int LMode= Integer.valueOf(request.getParameter("LMode"));
		if(LMode==1){// If Languagues Mode is On
			int FromID = Integer.valueOf(request.getParameter("From"));
			int ToID = Integer.valueOf(request.getParameter("To"));
			DictionariesBLO dictBLO = new DictionariesBLO();
            String Meaning = dictBLO.LookupWord(FromID, ToID, WTS);
            out.print(dictBLO.parseToHTML(Meaning));
		}else{// If Dictionary Mode is on
			int dictID = Integer.valueOf(request.getParameter("DictionaryID"));
			DictionariesBLO dictBLO = new DictionariesBLO();
          	String Meaning = dictBLO.lookupWord(dictID, WTS);
          	out.print(dictBLO.parseToHTML(Meaning));
		}
	}
%>